Repository navigation
fix(id): keep space-form --new from swallowing the subcommand (#3144) - #4326
Merged
Merged
Conversation
Cli::normalize_args rewrites a bare --new followed by a top-level subcommand name to --new= before clap parses, so the documented id --new serve runs serve under a random instance name instead of creating .iroh/serve/ and starting the REPL. Subcommand names come from the clap definition itself (names + aliases), so the list cannot drift. Named, equals, bare, and trailing forms are preserved; global flag values that spell a subcommand are not mistaken for one. main.rs parses through normalize_args. Tests: 3 new lib parse/normalize tests and 2 new CLI integration tests (space-form subcommand runs under an 8-hex random instance; space-form named instance). Existing --new integration tests still pass (6/6 test_new_flag*).
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 23 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3144. Queue task 5655.
Problem
--newis a globalOption<String>withnum_args = 0..=1, so clap greedily consumes the next token as the instance name. The documentedid --new servecreated.iroh/serve/and started the REPL instead of serving under a random name.Change
pkgs/id/src/cli.rs: newCli::normalize_argsargv pre-pass. When a bare--newis followed by a top-level subcommand name (and no subcommand has been seen yet), it rewrites that--newto--new=— the empty value still means "random name" and the token then parses as the subcommand. The name set is read from the clap definition itself (names + aliases), so it cannot drift from the real parser. Global flag values that spell a subcommand (e.g.--log-level list) are not mistaken for one, and everything after--is left alone.pkgs/id/src/main.rs: parse throughnormalize_args(std::env::args_os()).--new,--new=<name>,--new <name> <command>, trailingserve --new. No--data-dirbehavior change.Tests (laptop, head 7fc37e8)
test_cli_parse_new_space_form_subcommand_not_swallowed,test_cli_parse_new_forms_preserved,test_normalize_args_rewrites_only_the_ambiguous_form— all pass. (They parse on a big-stack thread, the module's existing convention for deep clap parses.)test_new_flag_space_form_subcommand_not_swallowed(id --new idsucceeds, creates exactly one 8-hex instance dir, no.iroh/id/),test_new_flag_space_form_named— pass. Fulltest_new_flag*set: 6/6 pass.test_cli_parse_world_new_and_statsstack-overflows in this laptop's libtest setup on unmodified branch state too (verified on the fleet/5215 worktree); it does not use the big-stack workaround the neighboring parse tests use.Need help on this PR? Tag
@codesmith-botwith what you need.